Write an improved code for finding prime numbers from 2 to N. Here you have to get the N value from the user. Store the prime numbers as we are finding them in the list. Use a user-defined block to check if a number is a prime number and insert it into a list. Refer to14th lesson’s exercise -1 to develop this code by using lists and blocks.
Teachers should teach my blocks by using simple mathematical sums before giving this exercise.
Teachers should give their own creative activity to help students understand user-defined functions. (Define functions for walking, running, jumping etc..)
Repeat the point from the last lesson. Explain how function blocks reduce the total number of blocks. How it abstracts one logic in one place so that it can be used at many places. This needs to be explained with real examples. Taking lift to floor “N”. Once you learn this once, you can do this in any building. If you need to support another kind of lift, change is required only in one place etc.
If you are doing exercise 3, point out how this would be faster than doing it without storing the previous primes in a list. We only have to check the prime numbers instead of all numbers till √N.